goog.provide('ol.Matrix');

goog.require('ol');

/**
 * @constructor
 * @api
 */
ol.Matrix = function() {
    this.mx = [1,0,0,1,0,0];
};


ol.Matrix.prototype.rotate = function (r) {
    var cos = Math.cos(r),
        sin = Math.sin(r),
        mx = this.mx,
        a = mx[0] * cos + mx[2] * sin,
        b = mx[1] * cos + mx[3] * sin,
        c = -mx[0] * sin + mx[2] * cos,
        d = -mx[1] * sin + mx[3] * cos;
    this.mx[0] = a;
    this.mx[1] = b;
    this.mx[2] = c;
    this.mx[3] = d;
    return this;
};

ol.Matrix.prototype.translate = function (x,y) {
    this.mx[4] += this.mx[0] * x + this.mx[2] * y;
    this.mx[5] += this.mx[1] * x + this.mx[3] * y;
    return this;
};
ol.Matrix.prototype.scale = function (x,y) {
    this.mx[0] *= x;
    this.mx[1] *= x;
    this.mx[2] *= y;
    this.mx[3] *= y;
    return this;
};

ol.Matrix.prototype.skew = function (x,y) {
    var tanX=Math.tan(x),
        tanY=Math.tan(y),
        mx0=this.mx[0],
        mx1=this.mx[1];
    this.mx[0] += tanY*this.mx[2];
    this.mx[1] += tanY*this.mx[3];
    this.mx[2] += tanX*mx0;
    this.mx[3] += tanX*mx1;
    return this;
};